﻿//----------------------------------------------------------------------------------------------------
// The InventoryManager is responsible for handling players inventories
//----------------------------------------------------------------------------------------------------

package HG.Managers
{
	import HG.Debug;
	import HG.GameService;
	
	import HG.GameDataTypes.ProfileStore;
	
	import HG.TypeInterfaces.ProfileStoreFileInterface;
	import HG.GameDataTypes.Profile;
	
	public class ProfileManager extends IGameManager
	{
		static var m_profileFileLocation:String = "Save//";
		static var m_profileFileName:String = "profiles";
		
		var m_profileStore:ProfileStore;
		
		//----------------------------------------------------------------------------------------------------
		public function ProfileManager()
		{
			
		}
			
		//----------------------------------------------------------------------------------------------------
		override public function Initialize()
		{
			LoadProfileStore();
		}
		
		//----------------------------------------------------------------------------------------------------
		override public function Shutdown()
		{
		}
		
		//----------------------------------------------------------------------------------------------------
		override public function OnTick(DeltaTime:Number)
		{
		}
		
		//----------------------------------------------------------------------------------------------------
		private function LoadProfileStore()
		{
			var storeFile:ProfileStoreFileInterface = new ProfileStoreFileInterface(m_profileFileLocation + m_profileFileName);
			storeFile.LoadStore(ProfileStoreLoaded);
		}
		
		//----------------------------------------------------------------------------------------------------
		private function ProfileStoreLoaded(store:ProfileStore)
		{
			Debug.ASSERT(store, "Loaded Profile Store does not exist!");
			
			if (!store)
			{
				m_profileStore = new ProfileStore();
				var newProfile:Profile = new Profile("1");
				m_profileStore.AddProfile(newProfile);
				
				var file:ProfileStoreFileInterface = new ProfileStoreFileInterface(m_profileFileName);
				file.SaveStore(m_profileStore);
			}
			
			
			m_profileStore = store;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function LoadProfile(profileID:String)
		{
			
		}
		
		//----------------------------------------------------------------------------------------------------
	}
}





